package com.czx.handler;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class HandlerHolder {

    @Bean
    public AbstractHandler limitHandler() {
        return new AbstractHandler() {
            @Override
            public boolean handle() {
                System.out.println("限流处理不通过");
                return false;
//                if (next != null) {
//                    return next.handle();
//                }
//                return true;
            }
        };
    }

    @Bean
    public AbstractHandler blackHandler() {
        return new AbstractHandler() {
            @Override
            public boolean handle() {
                System.out.println("黑名单处理");
                if (next != null) {
                    return next.handle();
                }
                return true;
            }
        };
    }

    @Bean
    public AbstractHandler tokenHandler() {
        return new AbstractHandler() {
            @Override
            public boolean handle() {
                System.out.println("token处理");
                if (next != null) {
                    return next.handle();
                }
                return true;
            }
        };
    }
}
